define(function(require) {
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");

	var Model = function() {
		this.callParent();
		this.menuDrop = justep.Bind.observable('1'); // 下拉菜单序号
		this.groupName = justep.Bind.observable('default'); // 公众号参数分组名称
	};

	Model.prototype.showPageClick = function(event) {
		var url = event.source.$domNode.attr('url') + '?groupName=default';
		var index = $(event.source.$domNode).index();
		var key = this.comp('keyData').getValue('fvalue');
		if (!key || key.length==0) {
			justep.Util.hint("尚未配置公众号参数！");
			return;
		}

		this.menuDrop.set(index + 1);
		this.comp('pageContainer').load(require.toUrl(url));
		
	};

	Model.prototype.keyDataAfterRefresh = function(event){
		var key = this.comp('keyData').getValue('fvalue');
		if (!key || key.length==0) {
			justep.Util.hint("尚未配置公众号参数！");
			return;
		}else{
			this.comp('pageContainer').load(require.toUrl('./editeMenu.w?groupName=default'));
		}
	};

	Model.prototype.groupsCustomerRefresh = function(event){
		var group = event.source;
		var append = event.options && event.options.append;
		var params = {
			"key" : "com.qq.weixin.mp.appID"
		};
		$.ajax({
			type : "GET",
			url : require.toUrl("/config/config/groups"),
			dataType : "json",
			async : false,// 使用同步方式，目前data组件有同步依赖
			cache : false,
			data : params,
			success : function(res) {
				group.loadData(res);
				group.loadData(res,append);
				group.doRefreshAfter(true, event.options);
			}
		});
	}
	return Model;
});